package com.actimize.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.actimize.dao.PayeeDao;
import com.actimize.model.Payee;
import com.actimize.service.PayeeManager;

import java.util.List;


@Service("payeeManager")
public class PayeeManagerImpl extends GenericManagerImpl<Payee, Long> implements PayeeManager {
    private PayeeDao payeeDao;
    
    @Autowired
    public PayeeManagerImpl (PayeeDao payeeDao){
    	super(payeeDao);
    	this.payeeDao = payeeDao;
    }
    
    @Autowired
    public void setPayeeDao(PayeeDao payeeDao) {
        this.dao = payeeDao;
        this.payeeDao = payeeDao;
    }

    /**
     * {@inheritDoc}
     */
    public Payee getPayee(String payeeId) {
        return payeeDao.get(new Long(payeeId));
    }

    /**
     * {@inheritDoc}
     */
    public List<Payee> getPayees() {
        return payeeDao.getPayees();
    }

    /**
     * {@inheritDoc}
     */
    public Payee savePayee(Payee payee) {
        System.out.println(payee.toString());
    	try {
            return payeeDao.savePayee(payee);
        } catch (Exception e) {
            e.printStackTrace();
            log.warn(e.getMessage());
        }
        return payee;
    }

}
